<template>
  <div class="call-container">
    <van-nav-bar
      title="已联系家政人员"
      left-arrow
      @click-left="$router.back()"
    />
    <van-pull-refresh
      v-model="refreshing"
      @refresh="loadCall"
      :success-text="refreshSuccessText"
      success-duration="1200"
    >
      <van-list
        v-model="loading"
        :finished="finished"
        :finished-text="finishedText"
        @load="onLoad"
        :error.sync="error"
        error-text="请求失败，点击重新加载"
      >
        <div class="one">
          <van-swipe-cell v-for="(item, index) in list" :key="index">
            <van-card :title="item.name" :desc="item.phone" class="goods-card">
              <template #tags>
                <van-tag
                  plain
                  size="large"
                  v-for="(item1, index) in item.tags"
                  :key="index"
                  round
                  >{{ item1 }}</van-tag
                >
              </template>
              <template #thumb>
                <van-image :src="item.img"></van-image>
              </template>
              <template #bottom>
                <span>湖南前海优家网络科技有限公司</span>
              </template>
            </van-card>
          </van-swipe-cell>
        </div>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
import { getTechniciansById } from '@/api/servers'

export default {
  name: 'Called',
  components: {},
  props: {},
  data () {
    return {
      list: [], // 月嫂详细信息数据
      // 刷新
      loading: false,
      // 加载状态
      finished: false,
      // 刷新状态
      refreshing: false,
      error: false,
      // 下拉刷新成功文本提示
      refreshSuccessText: '刷新成功!',
      finishedText: '没有更多了'
    }
  },
  computed: {},
  watch: {},
  created () {
    this.loadCall()
  },
  mounted () { },
  methods: {
    async loadCall () {
      try {
        this.finishedText = '数据加载中......'
        const { data } = await getTechniciansById()
        this.list = data
        this.refreshSuccessText = '刷新成功!'
        this.loading = false
        this.refreshing = false
        this.finishedText = '没有更多了'
      } catch (err) {
        this.refreshSuccessText = '刷新失败!'
        this.loading = false
        this.refreshing = false
      }
    },
    onLoad () {
      this.loading = true
      try {
        // 判断数据是否全部加载完成
        // 没有数据 将finished 设置为true
        this.finished = true
      } catch (err) {
        this.error = true
      }
      this.Loading = false
    }
  }
}
</script>

<style lang="less" scoped>
.van-nav-bar {
  position: fixed;
  top: 0;
  width: 100%;
  height: 98px;
  padding-top: 78px;
  background-color: #3f51b5;
}
.one {
  margin-top: 168px;
}
.van-swipe-cell {
  margin-bottom: 10px;
}
/deep/.van-nav-bar__content {
  top: -10px;
}
/deep/.van-nav-bar__title {
  color: #fff;
  font-size: 32px;
  font-weight: 600;
  margin-left: 75px;
}

.van-tag--large {
  margin-top: 23px;
  margin-right: 12px;
}
/deep/.van-icon-arrow-left::before {
  font-weight: 600;
  color: #fff;
}
/deep/.van-multi-ellipsis--l2[data-v-2c1f9e24] {
  display: inline;
  margin-right: 200px;
  font-size: 36px;
}
.van-ellipsis {
  display: inline-block;
  color: #000;
  font-size: 36px;
  margin-top: 5px;
}
.van-card {
  /deep/.van-card__thumb img {
    border-radius: 0;
  }
  /deep/.van-tag--default.van-tag--plain {
    color: #4b5bb9;
  }
  .goods-card {
    margin: 0;
    background-color: #fff;
  }

  .delete-button {
    height: 100%;
  }
}
</style>
